<template>
  <div class="bottom-bar">
    <div class="tool-item">
      <i class="icon service"></i>
      <span class="text">客服</span>
    </div>
    <div class="tool-item">
      <i class="icon shop"></i>
      <span class="text">店铺</span>
    </div>
    <div class="tool-item">
      <i class="icon" :class="{ 'collect': isCollect }"></i>
      <span class="text" @click="handleCollect"
        >收藏</span
      >
    </div>
    <button class="btn_cart" @click="handleCartAdd">加入购物车</button>
    <button class="btn_buy" >立即购买</button>
  </div>
</template>

<script>
import { mapState } from "vuex";

export default {
  name: "DetailBottomBar",
  props: ["iid"],
  data() {
    return {};
  },
  computed: {
    ...mapState(["collectList"]),
    isCollect() {
      return this.collectList.some((v) => v.iid == this.iid);
    },
  },
  mounted() {},

  methods: {
    handleCartAdd() {
      this.$emit("addCart");
    },
    handleCollect() {
      this.$emit("handleCollect");
    },
 
    
  },
};
</script>

<style lang="less" scoped>
.bottom-bar {
  
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 58px;

  background-color: #fff;
  display: flex;
  text-align: center;
  align-items: center;
}

.tool-item {
  flex: 1;
}
button {
  line-height: 58px;
  color: #fff;
  flex: 2;
  font-weight: 600;
}
.btn_cart {
  background-color: #ffa500;
}
.btn_buy {
  background-color: var(--color-tint);
}
.icon {
  display: block;
  width: 22px;
  height: 22px;
  background: url("~assets/img/detail/detail_bottom.png");
  background-size: cover;
  margin: 0 auto;
}
.service {
  background-position: 0 -54px;
}

.shop {
  background-position: 0 -98px;
}
.collect {
  background-position: 0 -27px;
}
</style>
